package com.dingzhen.msg.service.impl;

import com.dingzhen.config.MqttConfig;
import com.dingzhen.entity.Msg;
import com.dingzhen.msg.service.SendService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@Service
public class SendServiceImpl implements SendService {
    @Resource
    private MqttConfig.MyGateway gateway;

    @Override
    public void send(Msg message, String userId) {
        gateway.sendToMqtt(message.toString(), userId);
    }

    @Override
    public void send(Msg message, List<String> userIdList) {
        for (String userId : userIdList) {
            gateway.sendToMqtt(message.toString(), userId);
        }
    }

    @Override
    public void sendAll(Msg message) {

    }
}
